<?php

// Init owncloud

require_once(OC_App::getAppPath('resumes') . "/lib/helper.php");

$companyid = 0; 
if(!OC_User::isLoggedIn()) {
   $app = PFactory::getApplication(); 
   $companyid = $app->getUserState('resumeshare_companyid', 0); 
   if(!$companyid) {
      exit;
   }
}

$resumeid = JRequest::getInt('id', 0);
$imgfile = JRequest::getString('img', ''); 

if(empty($resumeid) || empty($imgfile))
   exit; 

$resumes = PResumeController::getResumeAsFiles($companyid);
if(empty($resumes)) {
   exit;
}

// only allow view one resume at a time      
$resume = $resumes[0];

$datadir = getUserDataDir($companyid); 
$folder = dirname(OC::$SERVERROOT."/data".$datadir."/company/" . $resume->resumefile); 

// currently getimage only support 51job image 
$imgfile = $folder . "/51job/" . $imgfile; 
echo file_get_contents($imgfile); 
